<!DOCTYPE html>
<html>
<head>
<title>Cookie 测试</title>
<meta charset="UTF-8">
<script type="text/javascript" src="/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="/js/jquery.cookie.js"></script>
<!-- <script src="https://cdn.staticfile.org/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script> -->

<script type="text/javascript">
	function createCookie() {
		//创建一个cookie并设置 cookie的有效路径
		var c = $.cookie("JSESSIONID", "741213asd", {
			expires: 1,
			path: '/',
			secure: false
		});
		var b = $.cookie("USER", "741213asd", {
			expires: 1,
			path: '/',
			secure: false
		});
		console.log(c);
		console.log(b);
	}
	function showCookieJson() {
		var obj = $.cookie("JSESSIONID");
		var jsonJS = eval("("+obj+")");
		console.log(jsonJS);
		
		var user = $.cookie("USER");
		var jsonUser = eval("("+user+")");
		console.log(jsonUser);
	}
</script>
</head>
<body>
	<h3>Cookie 测试</h3>
	<input type="button" onclick="createCookie()" value="创建一个有效路径为“/”且一天后过期的cooking" />
	<br />
	<input type="button" onclick="showCookieJson()" value="获得cookir中的json数据" />
	<br />
	<form action="/cookies" method="post" enctype="application/x-www-form-urlencoded">
		姓名：<input type="text" name="name" value="zs" /><br />
		密码：<input type="password" name="pwd" value="123456" /><br />
		<input type="submit" value="登录" />
	</form>
</body>